<%@ include file="/common/taglibs.jsp"%>

<head>
<title><fmt:message key="copyrightAlterationDetail.title" /></title>
<meta name="heading"
	content="<fmt:message key='copyrightAlterationDetail.heading'/>" />
</head>

<c:set var="delObject" scope="request">
	<fmt:message key="copyrightAlterationList.copyrightAlteration" />
</c:set>
<script type="text/javascript">
	var msgDelConfirm = "<fmt:message key="delete.confirm"><fmt:param value="${delObject}"/></fmt:message>";
</script>

<%-- <div class="span2">
    <h2><fmt:message key="copyrightAlterationDetail.heading"/></h2>
    <fmt:message key="copyrightAlterationDetail.message"/>
</div> --%>

<div class="span7">
	<s:form id="copyrightAlterationForm" action="saveCopyrightAlteration"
		theme="bootstrap"
		label="%{getText('copyrightAlterationDetail.heading')}" method="post"
		validate="true" cssClass="form-horizontal">
		<s:hidden key="copyrightAlteration.id" />
		
		<s:hidden name="copyrightAlteration.items"/>
		<s:hidden name="copyrightAlteration.beforeContent"/>
		<s:hidden name="copyrightAlteration.afterContent"/>
		
		<p />
 
		<fieldset>
			<legend>
				<fmt:message key="copyrightAlteration.title.softFullName" />
			</legend>
			<ul class="item">
				<s:textfield key="copyrightAlteration.softFullName" required="true"/>
				
				<div class="control-group">
					<label class="control-label"> 
						<fmt:message key="copyrightAlteration.originalRegType" />
					</label>
					<div class="controls">
						<label class="radio inline"> 
							<input id="copyrightAlteration-originalRegType-0" type="radio" name="copyrightAlteration.originalRegType" value="<s:property value="constantValues['copyrightAlteration.originalRegType.reg']"/>"/>
							<fmt:message key="copyrightAlteration.originalRegType.reg" />
						</label>
						<label class="radio inline"> 
							<input id="copyrightAlteration-originalRegType-1" type="radio" name="copyrightAlteration.originalRegType" value="<s:property value="constantValues['copyrightAlteration.originalRegType.transferReg']"/>"/>
							<fmt:message key="copyrightAlteration.originalRegType.transferReg" />
						</label> 
						<label class="radio inline"> 
							<input id="copyrightAlteration-originalRegType-2" type="radio" name="copyrightAlteration.originalRegType" value="<s:property value="constantValues['copyrightAlteration.originalRegType.proprietaryReg']"/>"/>
							<fmt:message key="copyrightAlteration.originalRegType.proprietaryReg" />
						</label> 
					</div>
				</div>
				
				<s:textfield key="copyrightAlteration.originalRegNumber"
					required="true" maxlength="40" />

				<s:textfield key="copyrightAlteration.originalChangeNumber"
					 maxlength="40" />
			</ul>
		</fieldset>
		
		<fieldset>
			<legend>
				<fmt:message key="copyrightAlteration.title.alterOrSupplyInfo" />
			</legend>
			<ul class="item">
				
				<div class="control-group">
					<label class="control-label"> 
						<fmt:message key="copyrightAlteration.applyingType" />
					</label>
					<div class="controls">
						<label class="radio inline"> 
							<input type="radio" id="copyrightAlteration-applyingType-0" name="copyrightAlteration.applyingType" value="<s:property value="constantValues['copyrightAlteration.applyingType.alteration']"/>"/>
							<fmt:message key="copyrightAlteration.applyingType.alteration" />
						</label>
						<label class="radio inline"> 
							<input id="copyrightAlteration-applyingType-1" type="radio" name="copyrightAlteration.applyingType" value="<s:property value="constantValues['copyrightAlteration.applyingType.supply']"/>"/>
							<fmt:message key="copyrightAlteration.applyingType.supply" />
						</label> 
					</div>
				</div>
				
			</ul>
			<div id="alterationContainer">
				<ul class="item">	
				<s:select  name="alterationTypes" value="%{copyrightAlteration.alterationItems[0].alterationType}"
						label="%{getText('copyrightAlteration.alterationType')}" list="alterationTypeList" listKey="value" listValue="label" required="true" />
				 
				<s:textarea name="originalContents" label="%{getText('copyrightAlteration.originalContent')}" required="true"
					cssClass="input-xxlarge" value="%{copyrightAlteration.alterationItems[0].originalContent}"/>
				<s:textarea name="alteredContents" label="%{getText('copyrightAlteration.alteredContent')}" required="true"
					cssClass="input-xxlarge" value="%{copyrightAlteration.alterationItems[0].alteredContent}"/>
					
				<div class="control-group">
					<div class="controls">
						<button id="btn_alterationItemAdd" type="button" class="btn btn-info"><fmt:message key="button.add" /></button>
						<button id="btn_alterationItemDel" type="button" class="btn btn-danger" onclick="delAlterationItem(this)"><fmt:message key="button.delete" /></button>
					</div>
				</div>
				</ul>
				
				<s:iterator  value="%{copyrightAlteration.alterationItems}" status="status" id="lists">
					<s:if test="%{#status.index != 0}">
						<ul class="item">
							<s:select  name="alterationTypes" value="%{#lists.alterationType}"
								label="%{getText('copyrightAlteration.alterationType')}" list="alterationTypeList" listKey="value" listValue="label" />
				
							<s:textarea name="originalContents"  value="%{#lists.originalContent}" label="%{getText('copyrightAlteration.originalContent')}"
								cssClass="input-xxlarge" />
							<s:textarea name="alteredContents"  value="%{#lists.alteredContent}" label="%{getText('copyrightAlteration.alteredContent')}"
								cssClass="input-xxlarge" /> 
					
							<div class="control-group">
								<div class="controls">
									<button id="btn_alterationItemAdd" type="button" class="btn btn-info"><fmt:message key="button.add" /></button>
									<button id="btn_alterationItemDel" type="button" class="btn btn-danger" onclick="delAlterationItem(this)"><fmt:message key="button.delete" /></button>
								</div>
							</div>
						</ul>
					</s:if>
				</s:iterator> 
			</div>
			
			
			<div id="supplyContainer">
				<ul class="item">
					
					<s:select label="%{getText('copyrightAlteration.supplyType')}" name="alterationTypes" value="%{copyrightAlteration.supplyItem.supplyType}" required="true"
						list="supplyTypeList" listKey="value" listValue="label" />
				
					<s:textarea label="%{getText('copyrightAlteration.supplyOrigContent')}" name="originalContents" value="%{copyrightAlteration.supplyItem.supplyOrigContent}" required="true"
						cssClass="input-xxlarge" />
					<s:textarea label="%{getText('copyrightAlteration.supplyNewlyContent')}" name="alteredContents" value="%{copyrightAlteration.supplyItem.supplyAlteredContent}" required="true"
						cssClass="input-xxlarge" />
				</ul>
				
			</div>
			
			<ul class="item">
				<s:textarea key="copyrightAlteration.reason"
						cssClass="input-xxlarge" />
			</ul>
		</fieldset> 
		
		
		<!-- Applier Profile BEGIN -->
		<fieldset>
			<legend><fmt:message key="copyrightAlteration.title.applierProfile" /> </legend>
			<ul class="item">
				
				<%-- <c:if test="${not empty copyrightAlteration.id}"> --%>
					<s:textfield key="copyrightAlteration.sqrname" required="true"/>
					<s:textfield key="copyrightAlteration.sqraddress" required="true"/>
					<s:textfield key="copyrightAlteration.sqrpostCode"/>
					<s:textfield key="copyrightAlteration.sqrcontactPerson" required="true"/>
					<s:textfield key="copyrightAlteration.sqrphone" required="true"/>
					<s:textfield key="copyrightAlteration.sqremail" required="true"/>
					<s:textfield key="copyrightAlteration.sqrmobile"/>
					<s:textfield key="copyrightAlteration.sqrfax"/>
				<%-- </c:if> --%>
				
				<%-- <c:if test="${empty copyrightAlteration.id}">
					<security:authentication property="principal" var="authentication" scope="request"/>
				
					<s:textfield key="copyrightAlteration.sqrname" required="true" value="%{#request.authentication.companyName}"/>
					<s:textfield key="copyrightAlteration.sqraddress" required="true" value="%{#request.authentication.address.address}"/>
					<s:textfield key="copyrightAlteration.sqrpostCode" value="%{#request.authentication.address.postalCode}"/>
					<s:textfield key="copyrightAlteration.sqrcontactPerson" required="true" value="%{#request.authentication.contact}"/>
					<s:textfield key="copyrightAlteration.sqrphone" required="true" value="%{#request.authentication.contactNumber}"/>
					<s:textfield key="copyrightAlteration.sqremail" required="true" value="%{#request.authentication.email}"/>
					<s:textfield key="copyrightAlteration.sqrmobile" value="%{#request.authentication.phoneNumber}"/>
					<s:textfield key="copyrightAlteration.sqrfax" value="%{#request.authentication.fax}"/>
				</c:if> --%>
			</ul>
		</fieldset> 
		<!-- Applier Profile END -->

		<!-- Agent Profile BEGIN -->
		<fieldset>
			<legend><fmt:message key="copyrightAlteration.title.agentProfile" /> </legend>
			<ul class="item">
				<div class="control-group ">
					<div class="controls">
						<fmt:message key="copyrightApplication.agentDesc" />
					</div>
				</div>
				<s:textfield name="copyrightAlteration.agentDesc" readonly="true"/>
				<s:textfield key="copyrightAlteration.dlrname" readonly="true"/>
				<s:textfield key="copyrightAlteration.dlraddress"  readonly="true"/>
				<s:textfield key="copyrightAlteration.dlrcontactPerson"  readonly="true"/>
				<s:textfield key="copyrightAlteration.dlremail"  readonly="true"/>
				<s:textfield key="copyrightAlteration.dlrfax"  readonly="true"/>
				<s:textfield key="copyrightAlteration.dlrmobile"  readonly="true"/>
				<s:textfield key="copyrightAlteration.dlrphone"  readonly="true"/>
				<s:textfield key="copyrightAlteration.dlrpostCode"  readonly="true"/>
			</ul>
		</fieldset> 
		<!-- Agent Profile END -->

		<div id="actions" class="form-actions">
			<security:authorize ifAllGranted="ROLE_USER">
				<s:if test="%{copyrightAlteration.state == null || copyrightAlteration.state != 2}">
				<s:submit type="button" cssClass="btn btn-primary" method="save" id="copyrightAlteration_button_save"
					key="button.save" theme="simple" onclick="return preSubmit();">
					<i class="icon-ok icon-white"></i>
					<fmt:message key="button.save" />
				</s:submit>
				</s:if>
			</security:authorize>
			<security:authorize ifAllGranted="ROLE_ADMIN">
				<s:if test="%{copyrightAlteration.state == 1}">
				<s:submit type="button" cssClass="btn btn-success" method="approve"  onclick="return preSubmit();" id="copyrightAlteration_button_approve"
					key="button.review.pass" theme="simple">
					<i class="icon-ok icon-white"></i>
					<fmt:message key="button.review.pass" />
				</s:submit>
				<s:submit type="button" cssClass="btn btn-danger" method="refuse"   id="copyrightAlteration_button_refuse"
					key="button.review.notPass" theme="simple" onclick="return preSubmit();">
					<i class="icon-ok icon-white"></i>
					<fmt:message key="button.review.notPass" />
				</s:submit>
				</s:if>
			</security:authorize>
			
			<s:submit type="button" cssClass="btn" method="cancel"
				key="button.cancel" theme="simple">
				<i class="icon-remove"></i>
				<fmt:message key="button.cancel" />
			</s:submit>
		</div>
	</s:form>
</div>

<script type="text/javascript">
	$(document).ready(
			function() {
				$("input[type='text']:visible:enabled:first",
						document.forms['copyrightAlterationForm']).focus();
				
				initFields();
			});
</script>

<c:set var="scripts" scope="request">
<%@ include file="/scripts/alterationForm.js"%>
</c:set>
